package com.cloudschool.ucenter.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cloudschool.ucenter.mapper.XcUserMapper;
import com.cloudschool.ucenter.model.dto.AuthParamsDto;
import com.cloudschool.ucenter.model.dto.XcUserExt;
import com.cloudschool.ucenter.model.po.XcUser;
import com.cloudschool.ucenter.service.AuthService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author chenhong
 * @version 1.0
 * @description TODO
 * @date 2023/3/19 19:55
 */
public class WxAuthServiceImpl implements AuthService {
    @Autowired
    XcUserMapper xcUserMapper;
    @Override
    public XcUserExt execute(AuthParamsDto authParamsDto) {
        //账号
        String username = authParamsDto.getUsername();
        XcUser user = xcUserMapper.selectOne(new LambdaQueryWrapper<XcUser>().eq(XcUser::getUsername, username));
        if(user==null){
            //返回空表示用户不存在
            throw new RuntimeException("账号不存在");
        }
        XcUserExt xcUserExt = new XcUserExt();
        BeanUtils.copyProperties(user,xcUserExt);
        return xcUserExt;
    }
}
